[C#] LINQ Group By


In some scenarios, we would like to select each first one row
of the group which we group by personId.

The following code block is a simple example.

var memberList =
    memberSourceData.GroupBy(item => item.personId)
        .Select(chunck => chunck
            .OrderByDescending(c => c.Id)
            .First())
        .ToList();
#C#






你可能感興趣的文章

瀏覽器的多進程與JS單線程

瀏覽器的多進程與JS單線程

[MTR04] W0 D1 看 Lidemy 課程影片

[MTR04] W0 D1 看 Lidemy 課程影片

Android Menu 實作踩坑紀錄

Android Menu 實作踩坑紀錄






留言討論